package com.hgyc.mom.eam.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.hgyc.mom.common.vo.Result;
import com.hgyc.mom.core.mybatis.QueryWrapperUtil;
import com.hgyc.mom.eam.entity.EamCheckMaintainPlanProgram;
import com.hgyc.mom.eam.service.EamCheckMaintainPlanProgramService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 设备点检保养计划项目Controller
 *
 * @author fwj
 * @since 2025-08-13
 */
@Tag(name = "设备点检保养计划项目控制器", description = "设备点检保养计划项目控制器")
@RestController
@RequestMapping("/eam/check/maintain/plan/program")
public class EamCheckMaintainPlanProgramController {
    @Autowired
    private EamCheckMaintainPlanProgramService eamCheckMaintainPlanProgramService;


    @Operation(summary = "查询设备点检保养计划项目树列表", description = "查询设备点检保养计划项目树列表")
    @PostMapping("/list")
    public Result<List<EamCheckMaintainPlanProgram>> pageList(@Parameter(description = "查询参数") @RequestBody EamCheckMaintainPlanProgram eamCheckMaintainPlanProgram) {
        QueryWrapper<EamCheckMaintainPlanProgram> wrapper = QueryWrapperUtil.build(eamCheckMaintainPlanProgram);
        List<EamCheckMaintainPlanProgram> list = eamCheckMaintainPlanProgramService.list(wrapper);
        return Result.success(list);
    }

    @Operation(summary = "获取设备点检保养计划项目详细信息", description = "获取设备点检保养计划项目详细信息")
    @GetMapping(value = "/{id}")
    public Result<EamCheckMaintainPlanProgram> getInfo(@Parameter(description = "设备点检保养计划项目ID") @PathVariable("id") Long id) {
        return Result.success(eamCheckMaintainPlanProgramService.getById(id));
    }

}
